package com.course.file.handler;

import com.course.server.common.Result;
import com.course.server.common.ResultEnum;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.BindException;
import org.springframework.validation.BindingResult;
import org.springframework.validation.FieldError;
import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import javax.validation.ConstraintViolationException;
import javax.validation.ValidationException;


/**
 * @author yangw
 * @created 2021/3/18
 * @description
 */
@Slf4j
@RestControllerAdvice(basePackages = "com.course.file")
public class ExceptionController {

    @ExceptionHandler({Exception.class, RuntimeException.class})
    public Result error(Exception e) {
        log.error("[未定义错误]", e);
        return Result.failure();
    }
}
